package com.yihubang.navigationcourse.taobao

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.NavController
import androidx.navigation.findNavController
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.setupWithNavController
import com.yihubang.navigationcourse.R
import kotlinx.android.synthetic.main.activity_taobao.*

/*
 * class title: 
 * Author by RenChunLin, Email 18957806320@163.com, Date on 2021/4/26.
 * PS: Not easy to write code, please indicate.
 */
class TaobaoActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_taobao)

        initView()
    }

    private fun initView() {
        //方法一：去fragment管理器里通过id找到NavHostFragment
        val navHostFragment =
            supportFragmentManager.findFragmentById(R.id.navigation_host_fragment) as NavHostFragment
        bottomNavigationView.setupWithNavController(navHostFragment.navController)

        //方法二：把androidx.fragment.app.FragmentContainerView改成fragment
        /*bottomNavigationView.setupWithNavController(
            findNavController(R.id.navigation_host_fragment)
        )*/
    }
}